package com.investmenttechnologyservices.util;

import com.google.appengine.tools.mapreduce.KeyValue;
import com.google.appengine.tools.mapreduce.Reducer;
import com.google.appengine.tools.mapreduce.ReducerInput;

public class SumReducer extends Reducer<String, Double, KeyValue<String, Double>> {
	private static final long serialVersionUID = 7719250524668822556L;

	@Override
	public void reduce(String key, ReducerInput<Double> values) {
		// log.info("reduce(" + key + ", " + values + ")");
		Double total = 0.0;
		while (values.hasNext()) {
			Double value = values.next();
			total += value;
		}
		getContext().emit(KeyValue.of(key, total));
	}
}
